package com.ruoyi.web.controller.golang;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.UserPic;
import com.ruoyi.system.service.IUserPicService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户照片墙图片Controller
 * 
 * @author ruoyi
 * @date 2025-01-12
 */
@Controller
@RequestMapping("/system/pic")
public class UserPicController extends BaseController
{
    private String prefix = "system/pic";

    @Autowired
    private IUserPicService userPicService;

    @RequiresPermissions("system:pic:view")
    @GetMapping()
    public String pic()
    {
        return prefix + "/pic";
    }

    /**
     * 查询用户照片墙图片列表
     */
    @RequiresPermissions("system:pic:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(UserPic userPic)
    {
        startPage();
        List<UserPic> list = userPicService.selectUserPicList(userPic);
        return getDataTable(list);
    }

    /**
     * 导出用户照片墙图片列表
     */
    @RequiresPermissions("system:pic:export")
    @Log(title = "用户照片墙图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(UserPic userPic)
    {
        List<UserPic> list = userPicService.selectUserPicList(userPic);
        ExcelUtil<UserPic> util = new ExcelUtil<UserPic>(UserPic.class);
        return util.exportExcel(list, "用户照片墙图片数据");
    }

    /**
     * 新增用户照片墙图片
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户照片墙图片
     */
    @RequiresPermissions("system:pic:add")
    @Log(title = "用户照片墙图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(UserPic userPic)
    {
        return toAjax(userPicService.insertUserPic(userPic));
    }

    /**
     * 修改用户照片墙图片
     */
    @RequiresPermissions("system:pic:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        UserPic userPic = userPicService.selectUserPicById(id);
        mmap.put("userPic", userPic);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户照片墙图片
     */
    @RequiresPermissions("system:pic:edit")
    @Log(title = "用户照片墙图片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(UserPic userPic)
    {
        return toAjax(userPicService.updateUserPic(userPic));
    }

    /**
     * 删除用户照片墙图片
     */
    @RequiresPermissions("system:pic:remove")
    @Log(title = "用户照片墙图片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(userPicService.deleteUserPicByIds(ids));
    }
}
